namespace CRMG.UserManagement.Source.QO
{
    /* Query Object Class */
    public class UserCrud
    {
        public static string GetUserList()
        {
            return "Select OBJID, FirstName+' '+LastName As Name From Users Where UserTypeId > 1;";
        }

        public static string GetUserByUserNameAndPass()
        {
            return "Select * From Users Where UserName=@UserName And Pass=@Pass And IsActive=1;";
        }
        
        public static string GetTrainers()
        {
            return "Select OBJID, FirstName + ' ' + LastName As Name From Users Where UserTypeId=5 And IsActive=1;";
        }

        public static string DeleteRolesOfUser()
        {
            return "Delete From UserRole Where UserId=@UserId;";
        }

        public static string DeleteOperationsOfRole()
        {
            return "Delete From RoleOperation Where RoleId=@RoleId;";
        }

        public static string GetOperationCodesOfUser()
        {
            return @"Select O.OperationCode From Operations O
                    Left Join RoleOperation RO on O.OBJID=RO.OperationId
                    Left Join UserRole UR on RO.RoleId=Ur.RoleId
                    Where UR.UserId=@UserId And O.IsActive=1;";
        }
    }
}
